package com.leo;

import javafx.concurrent.ScheduledService;
import javafx.concurrent.Task;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * @ClassName MyScheduledService
 * @Description
 * @Author wangss
 * @date 2020.06.20 22:52
 * @Version 1.0
 */
public class MyScheduledService extends ScheduledService<List<Integer>> {


    @Override
    protected Task<List<Integer>> createTask() {

        Task<List<Integer>> task = new Task<List<Integer>>() {
            @Override
            protected List<Integer> call() throws Exception {
                List<Integer> list = new ArrayList<>();

                Random ra = new Random();
                int value1 = ra.nextInt(100);
                int value2 = ra.nextInt(100);

                list.add(value1);
                list.add(value2);
                return list;
            }
        };

        return task;
    }
}
